namespace DotNetNuke.UI.Skins.Controls
{
    using DotNetNuke.Services.Exceptions;
    using DotNetNuke.UI.Skins;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Web.UI.WebControls;

    /// -----------------------------------------------------------------------------
    /// <summary></summary>
    /// <remarks></remarks>
    /// <history>
    /// [cniknet]	10/15/2004	Replaced public members with properties and removed
    /// brackets from property names
    /// </history>
    /// -----------------------------------------------------------------------------
    public class ModuleMessage : SkinObjectBase
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        private string _heading;
        private string _iconImage;
        private ModuleMessageType _iconType;
        //("imgIcon")]
        private Image _imgIcon;
        //("imgLogo")]
        private Image _imgLogo;
        //("lblHeading")]
        private Label _lblHeading;
        //("lblMessage")]
        private Label _lblMessage;
        private string _text;

       
        public ModuleMessage()
        {
            base.Init += new EventHandler(this.Page_Init);
            base.Load += new EventHandler(this.Page_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
        }

        private void Page_Init(object sender, EventArgs e)
        {
            this.InitializeComponent();
        }

        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string strMessage = "";
                if (this.IconImage != "")
                {
                    strMessage = strMessage + this.Text;
                    this.lblHeading.CssClass = "SubHead";
                    this.lblMessage.CssClass = "Normal";
                    this.imgIcon.ImageUrl = this.IconImage;
                    this.imgIcon.Visible = true;
                }
                else
                {
                    switch (this.IconType)
                    {
                        case ModuleMessageType.GreenSuccess:
                            strMessage = strMessage + this.Text;
                            this.lblHeading.CssClass = "SubHead";
                            this.lblMessage.CssClass = "Normal";
                            this.imgIcon.ImageUrl = "~/images/green-ok.gif";
                            this.imgIcon.Visible = true;
                            goto Label_018A;

                        case ModuleMessageType.YellowWarning:
                            strMessage = strMessage + this.Text;
                            this.lblHeading.CssClass = "Normal";
                            this.lblMessage.CssClass = "Normal";
                            this.imgIcon.ImageUrl = "~/images/yellow-warning.gif";
                            this.imgIcon.Visible = true;
                            goto Label_018A;

                        case ModuleMessageType.RedError:
                            strMessage = strMessage + this.Text;
                            this.lblHeading.CssClass = "NormalRed";
                            this.lblMessage.CssClass = "Normal";
                            this.imgIcon.ImageUrl = "~/images/red-error.gif";
                            this.imgIcon.Visible = true;
                            goto Label_018A;
                    }
                }
            Label_018A:
                this.lblMessage.Text = strMessage;
                if (this.Heading != "")
                {
                    this.lblHeading.Visible = true;
                    this.lblHeading.Text = this.Heading + "<br/>";
                }
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc, false);
                
            }
        }

        public string Heading
        {
            get
            {
                return this._heading;
            }
            set
            {
                this._heading = value;
            }
        }

        public string IconImage
        {
            get
            {
                return this._iconImage;
            }
            set
            {
                this._iconImage = value;
            }
        }

        public ModuleMessageType IconType
        {
            get
            {
                return this._iconType;
            }
            set
            {
                this._iconType = value;
            }
        }

        protected virtual Image imgIcon
        {
           
            get
            {
                return this._imgIcon;
            }
            
            set
            {
                this._imgIcon = value;
            }
        }

        protected virtual Image imgLogo
        {
           
            get
            {
                return this._imgLogo;
            }
            
            set
            {
                this._imgLogo = value;
            }
        }

        protected virtual Label lblHeading
        {
           
            get
            {
                return this._lblHeading;
            }
            
            set
            {
                this._lblHeading = value;
            }
        }

        protected virtual Label lblMessage
        {
           
            get
            {
                return this._lblMessage;
            }
            
            set
            {
                this._lblMessage = value;
            }
        }

        public string Text
        {
            get
            {
                return this._text;
            }
            set
            {
                this._text = value;
            }
        }

        public enum ModuleMessageType
        {
            GreenSuccess,
            YellowWarning,
            RedError
        }
    }
}

